<?php


namespace app\api\model\User;


use think\facade\Db;
use think\Model;

class UserVerifyCodeModel extends Model
{

    /**
     * 数据表名
     * @var string
     */
    protected $name = "user_verify_code";

    /**
     * 根据条件查询单挑数据
     * @param $where
     * @param string $filed
     * @return array|Model|null
     * @throws
     */
    public static function getUserVerifyCodeWhere($where,$filed = "*")
    {
        $code = Db::name("user_verify_code")->field($filed)->order('id desc')->where($where)->find();
        return $code;
    }


    /**
     * 统计总数
     * @param $where
     * @return int
     */
    public static function getUserVerifyCodeCountWhere($where)
    {
        $count = Db::name("user_verify_code")->where($where)->count();
        return $count;
    }


    /**
     * 添加返回ID
     * @param $data
     * @return int
     */
    public static function addUserVerifyCode($data)
    {
        $id = Db::name('user_verify_code')->insertGetId($data);
        return $id;
    }

    /**
     * 更新
     * @param $where
     * @param $save
     * @return int
     * @throws
     */
    public static function updateUserVerifyCodeWhere($where,$save)
    {
        $flag = Db::name('user_verify_code')->where($where)->update($save);
        return $flag;
    }

}